package com.chem.lems.controller;

import com.chem.lems.entity.User;
import com.chem.lems.serves.LoginServies;
import com.chem.lems.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginServies loginServies;

    /**
     * 登录
     * @param fromUser
     * @return
     */
    @PostMapping()
    public ResultUtil login(@RequestBody User fromUser) {
        return loginServies.login(fromUser);
    }

    /**
     * 登出
     * @param userId
     * @return
     */
    @DeleteMapping("{userId}")
    public ResultUtil outLogin (@PathVariable("userId") String userId) {
        return loginServies.outLogin(userId);
    }
}
